﻿// TestCpp.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//


#if 0
#include <iostream>
#include <string>
using namespace std;


// 自己赋值给自己
class MyObj {
public:
    MyObj() {
        cout << "ctor MyObj" << endl;
    }

    MyObj(const MyObj& other) {
        cout << "copy ctor MyObj" << endl;
    }

    MyObj& operator=(const MyObj& other) {
        cout << "assign ctor MyObj" << endl;

        if (this == &other) {
            // 自己赋值给自己
            cout << "自己赋值给自己" << endl;
        }

        return *this;
    }

    ~MyObj() {
        cout << "deCtor MyObj" << endl;
    }
};


int main()
{
    //std::cout << "Hello World!\n";

    MyObj obj1;
    MyObj& obj2 = obj1;
    MyObj& obj3 = obj1;
    obj3 = obj2;

    cout << "程序结束" << endl;
    getchar();

    return 0;
}

#endif

